cmake_minimum_required(VERSION 3.15)
project(mcommon C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_BUILD_TYPE debug)
set(HEADERS
        strings.h
        json.h
        cJSON.h
        struct2json.h
        map.h
        list.h
        logger.h
        file.h
        threads.h
        md5.h
        timer.h
        yml.h
        uuid.h
        base64.h
        randomstr.h
        mhttp.h
        http.h
        )
include_directories(/usr/local/include /usr/include /usr/include/curl)
add_library(mcommon SHARED
        strings.c
        strings.h
        json.c
        json.h
        cJSON.c
        cJSON.h
        struct2json_impl.c
        struct2json.c
        struct2json.h
        map.c
        map.h
        list.c
        list.h
        logger.c
        logger.h
        file.c
        file.h
        threads.c
        threads.h
        md5.c
        md5.h
        timer.h
        timer.c
        yml.c
        yml.h
        uuid.c
        uuid.h
        base64.c
        base64.h
        randomstr.c
        randomstr.h
        array.c
        array.h
        mhttp.c
        mhttp.h http.c http.h)
link_directories(/usr/lib /usr/local/lib)
link_libraries(yaml pthread curl ghttp)
target_link_libraries(mcommon -lpthread -lcurl -lyaml -lghttp)
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${HEADERS}")
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION /usr/local/lib
        PUBLIC_HEADER DESTINATION /usr/local/include)
